<template>
  <div class="card-list" ref="tabsRef">
    <div class="card-item" v-for="role in roleList" :key="role.id">
      <el-card class="card" body-class="card-body">
        <!-- 更多操作 -->
        <div class="more-container" v-if="false">
          <el-dropdown>
            <span class="el-dropdown-link">
              <el-button type="text">
                <el-icon><More /></el-icon>
              </el-button>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item :command="['edit', role]"> <Icon icon="ep:edit" color="#787878" />编辑 </el-dropdown-item>
                <el-dropdown-item :command="['delete', role]" style="color: red">
                  <Icon icon="ep:delete" color="red" />删除
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
        <!-- 角色信息 -->
        <div>
          <img class="avatar" :src="role.avatar" />
        </div>
        <div class="right-container">
          <div class="content-container">
            <div class="title">{{ role.name }}</div>
            <div class="description">{{ role.description }}</div>
          </div>
          <div class="btn-container">
            <el-button type="primary" size="small">使用</el-button>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";

const roleList = ref([]);
</script>

<style lang="scss">
// 重写 card 组件 body 样式
.card-body {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  width: 240px;
  max-width: 240px;
  padding: 15px 15px 10px;
}
</style>
<style scoped lang="scss">
// 卡片列表
.card-list {
  position: relative;
  display: flex;
  flex-flow: row wrap;
  place-content: flex-start start;
  align-items: start;
  height: 100%;
  padding: 0 25px;
  padding-bottom: 140px;
  overflow: auto;
  .card {
    position: relative;
    display: inline-block;
    margin-right: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    .more-container {
      position: absolute;
      top: 0;
      right: 12px;
    }
    .avatar {
      width: 40px;
      height: 40px;
      overflow: hidden;
      border-radius: 10px;
    }
    .right-container {
      width: 100%;
      margin-left: 10px;

      //height: 100px;
      .content-container {
        height: 85px;
        .title {
          font-size: 18px;
          font-weight: bold;
          color: #3e3e3e;
        }
        .description {
          margin-top: 10px;
          font-size: 14px;
          color: #6a6a6a;
        }
      }
      .btn-container {
        display: flex;
        flex-direction: row-reverse;
        margin-top: 2px;
      }
    }
  }
}
</style>
